<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>pcm在线播放</title>
	</head>
	<body style="text-align: center;">
		<div style="padding: 30px;">默认码率 16k 16 1 channel</div>
		<input type="file" id="fileInput" accept=".pcm" multiple="multiple" />
		<div id="audioList"></div>
	</body>
	<script src="./js/pcm.js"></script>
	<script>
		var fileUploader = document.getElementById('fileInput');
		fileUploader.addEventListener('change', function(e) {
			var filesList = document.querySelector('#fileInput').files;
			if (filesList.length == 0) {
				console.log("没有上传任何文件");
				return;
			} else {
				console.log(filesList);
				for (var i = 0; i < filesList.length; i++) {
					var file = filesList[i];
					console.log(file);
					var previewURL = URL.createObjectURL(file);
					pcm2wav(previewURL, 16000, 16, 1, function(e) {
						var _audioControl = document.createElement('audio');
						_audioControl.src = e;
						_audioControl.id = file.name;
						_audioControl.controls = true;
						// _audioControl.volume = '0.2';
						
						var _label = document.createElement('lable');
						_label.append(file.name);
						
						var div = document.createElement('div');
						div.append(_label);
						div.append(_audioControl);
						
						document.getElementById('audioList').append(div);
					});
				}
			}
		});
	</script>
</html>
